﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using M3G;

namespace MyTestProject {
    public class TestRenderTarget {
        [Fact]
        public void TestConstructor1 () {
            var img = new Image2D (Image2D.RGB, 256, 256);
            var target = new RenderTarget (img, 1);

            Assert.Equal (img, target.Target);
            Assert.Equal (1, target.TargetLevel);
        }

        [Fact]
        public void TestConstructor2 () {

            var img = new ImageCube (ImageCube.RGB, 256);
            var target = new RenderTarget (img, ImageCube.PosY, 1);

            Assert.Equal (img, target.Target);
            Assert.Equal (1, target.TargetLevel);
            Assert.Equal (ImageCube.PosY, target.TargetFace);
        }

        [Fact]
        public void TestReferences () {
            var img = new Image2D (Image2D.RGB, 256, 256);
            var target = new RenderTarget (img, 1);

            var refs = target.References;

            Assert.Equal (1, refs.Length);
            Assert.Equal (img, refs[0]);
        }

        [Fact]
        public void TestDuplicate () {
            var img = new Image2D (Image2D.RGB, 256, 256);
            var target = new RenderTarget (img, 1);
            target.UserID = 100;

            var dup = (RenderTarget)target.Duplicate ();

            Assert.Equal (target.Target, dup.Target);
            Assert.Equal (target.TargetLevel, dup.TargetLevel);
            Assert.Equal (target.UserID, dup.UserID);
        }
    }
}
